package org.openjsonp.json;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;

import javax.json.JsonNumber;

/**
 * Implementation of the interface {@link javax.json.JsonNumber JsonNumber}.
 * <p>
 * This class is a subclass of {@link BigDecimal}.
 * </p>
 * 
 */
public class JsonNumberImpl extends BigDecimal implements JsonNumber {

	private static final long serialVersionUID = -2793273472781530387L;

	/**
	 * Default constructor.
	 * <p>
	 * The JsonNumber is initialized to the value <code>0</code>.
	 * </p>
	 */
	public JsonNumberImpl() {
		super(0);
	}

	public JsonNumberImpl(char[] in) {
		super(in);
	}

	public JsonNumberImpl(String val) {
		super(val);
	}

	public JsonNumberImpl(double val) {
		super(val);
	}

	public JsonNumberImpl(BigInteger val) {
		super(val);
	}

	public JsonNumberImpl(int val) {
		super(val);
	}

	public JsonNumberImpl(long val) {
		super(val);
	}

	public JsonNumberImpl(char[] in, MathContext mc) {
		super(in, mc);
	}

	public JsonNumberImpl(String val, MathContext mc) {
		super(val, mc);
	}

	public JsonNumberImpl(double val, MathContext mc) {
		super(val, mc);
	}

	public JsonNumberImpl(BigInteger val, MathContext mc) {
		super(val, mc);
	}

	public JsonNumberImpl(BigInteger unscaledVal, int scale) {
		super(unscaledVal, scale);
	}

	public JsonNumberImpl(int val, MathContext mc) {
		super(val, mc);
	}

	public JsonNumberImpl(long val, MathContext mc) {
		super(val, mc);
	}

	public JsonNumberImpl(char[] in, int offset, int len) {
		super(in, offset, len);
	}

	public JsonNumberImpl(BigInteger unscaledVal, int scale, MathContext mc) {
		super(unscaledVal, scale, mc);
	}

	public JsonNumberImpl(char[] in, int offset, int len, MathContext mc) {
		super(in, offset, len, mc);
	}

	@Override
	public ValueType getValueType() {
		return ValueType.NUMBER;
	}

	@Override
	public boolean isIntegral() {
		return scale() == 0;
	}

	@Override
	public BigInteger bigIntegerValue() {
		return toBigInteger();
	}

	@Override
	public BigInteger bigIntegerValueExact() {
		return toBigIntegerExact();

	}

	@Override
	public BigDecimal bigDecimalValue() {
		return this;
	}
}
